/*
 * kkMainWindow.java
 *
 * Created on December 23, 2006, 4:53 PM
 */

package kkWindows;

/**
 *
 * @author  Kowshik
 **/

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JDialog;
import javax.swing.JOptionPane;

public class kkMainWindow extends javax.swing.JFrame {
    
    /** Creates new form kkMainWindow */
    
    private kkScanWindow scanWindow;
    private kkUpdateWindow updateWindow;
    
    public kkMainWindow() {
        initComponents();
        
    }
    
   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        scannerInitButton = new javax.swing.JButton();
        updateInitButton = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("KillerKitty Virus Scanner");
        scannerInitButton.setText("SCAN");
        scannerInitButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                scannerInitButtonMouseClicked(evt);
            }
        });

        updateInitButton.setText("UPDATE");
        updateInitButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                updateInitButtonMouseClicked(evt);
            }
        });

        jButton3.setText("OPTIONS");

        jButton4.setText("ABOUT");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(scannerInitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(updateInitButton, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(scannerInitButton)
                .addComponent(jButton4)
                .addComponent(jButton3)
                .addComponent(updateInitButton))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        JOptionPane.showMessageDialog(this,"KillerKitty Virus Scanner v1.0\nCreators : R.Sanjay Prabu, N.R.Ragavendar, P.Kowshik","About",JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jButton4ActionPerformed
//Creates and displays a new update window
    private void updateInitButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_updateInitButtonMouseClicked
        updateWindow=new kkUpdateWindow(this,true);
        updateWindow.setResizable(false);
        updateWindow.addWindowListener(new kkUpdateWindowListener());
        updateWindow.show();
    }//GEN-LAST:event_updateInitButtonMouseClicked
//Creates and displays a new scan window
    private void scannerInitButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_scannerInitButtonMouseClicked
        scanWindow=new kkScanWindow(this,true);
        scanWindow.setResizable(false);
        scanWindow.addWindowListener(new kkScanWindowListener());
        scanWindow.show();
    }//GEN-LAST:event_scannerInitButtonMouseClicked
    
    /**
     * @param args the command line arguments
     */
    
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton scannerInitButton;
    private javax.swing.JButton updateInitButton;
    // End of variables declaration//GEN-END:variables
    

    class kkScanWindowListener extends WindowAdapter{
        public void windowClosing(WindowEvent event){
            kkScanWindow scanWindow=((kkScanWindow)(event.getSource()));
            if(scanWindow.bgWorker!=null)
                scanWindow.bgWorker.cancel(true);
            
            scanWindow.pack();
            
        }
    }
    class kkUpdateWindowListener extends WindowAdapter{
        public void windowClosing(WindowEvent event){
            ((JDialog)(event.getSource())).pack();
        }
    }

}


